Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Bindmount the sysfs into our root_dir" #97

Closed
wants to merge 1 commit into from

Conversation

staticfloat
Copy link
Owner

It turns out that we can't bindmount sysfs if we're using the
unprivileged executor, which is our favorite executor to use.
X-ref: nestybox/sysbox#67 (comment)

This reverts commit a58ccf0.

It turns out that we can't bindmount `sysfs` if we're using the
unprivileged executor, which is our favorite executor to use.
X-ref: nestybox/sysbox#67 (comment)

This reverts commit a58ccf0.
@staticfloat
Copy link
Owner Author

@DilumAluthge @Keno I just pushed through a new version of UserNSSandbox_jll and found that this commit broke our ability to use unprivileged user namespaces.

Apparently the Linux kernel puts restrictions on who can mount sysfs. Keno, do you have any magic incantations that we can use to get this to magically work?

staticfloat added a commit to JuliaRegistries/General that referenced this pull request Jul 29, 2022
This version introduced a bug for some important users, let's yank it.

X-ref: staticfloat/Sandbox.jl#97
@Keno
Copy link
Contributor

Keno commented Jul 29, 2022

Hmm, but that's about mounting the sysfs directly. Here we're just bindmounting, which should always be allowed.

@staticfloat
Copy link
Owner Author

Okay you prompted me to look a bit deeper, strace shows the following:

[pid 3992451] mount("/sys", "/home/sabae/.julia/artifacts/562768a40e93d27b79fbedf9cfa7883409d494ea//sys", 0x4894c7, MS_BIND|MS_REC, NULL) = 0
[pid 3992451] mount("/sys", "/home/sabae/.julia/artifacts/562768a40e93d27b79fbedf9cfa7883409d494ea//sys", 0x4894c7, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND, NULL) = -1 EPERM (Operation not permitted)

So it looks like the first mount passes, but when we try to remount, it fails. I guess that's not surprising since we're asking for things like MS_NODEV, which likely wouldn't work. This is coming from this branch, which we do only when we're asking for a read-only bindmount. Should we mount /sys without trying to remount, or should we alter the flags somewhat?

@Keno
Copy link
Contributor

Keno commented Jul 30, 2022

I suspect you are correct that the issue is MS_NODEV. Try dropping that: https://github.com/torvalds/linux/blob/952923ddc01120190dcf671e7b354364ce1d1362/fs/namespace.c#L2569-L2571

@maleadt
Copy link
Contributor

maleadt commented Aug 1, 2022

I suspect you are correct that the issue is MS_NODEV. Try dropping that: https://github.com/torvalds/linux/blob/952923ddc01120190dcf671e7b354364ce1d1362/fs/namespace.c#L2569-L2571

We need MS_NODEV, because that code path prevents us from clearing it on remount. In addition, we need to preserve noexec, because /sys here is mounted with nosuid,nodev,noexec. That's the actual issue here, already noted by a TODO in the sandbox source code.

@Keno
Copy link
Contributor

Keno commented Aug 1, 2022

We need MS_NODEV, because that code path prevents us from clearing it on remount. In addition, we need to preserve noexec, because /sys here is mounted with nosuid,nodev,noexec. That's the actual issue here, already noted by a TODO in the sandbox source code.

Ah, good catch.

@maleadt
Copy link
Contributor

maleadt commented Aug 1, 2022

I'll have a look at fixing this, by parsing procfs (fdinfo and mountinfo) according to that TODO.

@staticfloat staticfloat closed this Aug 1, 2022
DilumAluthge added a commit to JuliaRegistries/General that referenced this pull request Aug 10, 2022
Yank bad UserNSSandbox_jll version

This version introduced a bug for some important users, let's yank it.

X-ref: staticfloat/Sandbox.jl#97

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants